#!/bin/bash

oldVersion=1.0
version=1.0
# 应用基本信息
projectName=spring-amazon
port=9091
innerPort=9091
# 进入java项目
cd ../spring-tracker-server
# 打jar包
mvn install -DskipTests
# 查看运行的pid
pid=$(docker ps -a | grep -c $projectName)
# 打镜像
if [ "$pid" -eq 1 ];then
	echo "Container exist, pid is $pid, ready to rm container..."
	docker rm -f $projectName
	docker rmi -f $projectName:$oldVersion
	docker build -t $projectName:$version .
else
	echo "Cant remove container, pid is $pid"
  docker build -t $projectName:$version .
fi